import java.util.Scanner;



// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
            int q = in.nextInt();
            in.nextLine();
            while(q-->0) {
            	String number =in.nextLine();
            	char[]chars=number.toCharArray();
            	int len=chars.length;
            	boolean flag=false;
            	
            	for(int i=len-2;i>=0;i--) {
            		if((chars[i]-'0')%2==0) {
            			swap(chars,i,len-1);
            			flag=true;//?
            			break;
            		}
            	}
            	
            	if(flag) {
            		System.out.println(new String(chars));
            	}else {
            		//System.out.println(-1);
            		boolean hasEven=false;
            		for(char c:chars) {
            			if((c-'0')%2==0) {
            				hasEven=true;
            				break;
            			}
            		}
            		System.out.println(hasEven?new String(chars):-1);
            	}
            }
            in.close();
        }
    private static void swap(char[]chars,int i,int j) {
    	char temp=chars[i];
    	chars[i]=chars[j];
    	chars[j]=temp;
    }
    }
